/*
*
* Copyright (C) 2004 - 2008 BitLaboratory (see http://www.bitlaboratory.com)
* All rights reserved. 
*
* Redistribution and use in source and binary forms, with or without modification, 
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
*    this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
*    this list of conditions and the following disclaimer in the documentation
*    and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
*    derived from this software without specific prior written permission. 
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
* OF SUCH DAMAGE.
*
* You can find the latest version of this library at http://www.bitlaboratory.com
*
*/


using System;
using System.Text;
using System.Runtime.InteropServices;
using BitLaboratory.Win32Api.Drawing;


namespace BitLaboratory.Win32Api.Themes
{
#if( _SHARED_ )
	internal class APITheme
#else
	public class APITheme
#endif
	{
		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 CloseThemeData(IntPtr hTheme);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, [In] COMRECT pRect, [In] COMRECT pClipRect);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, IntPtr pClipRect);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, IntPtr pRect, IntPtr pClipRect);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeBackgroundEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, ref DTBGOPTS poptions);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeEdge(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pDestRect, uint egde, uint flags, out RECT pRect);
		
		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeEdge(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pDestRect, uint egde, uint flags, int pRect);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeIcon(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, IntPtr himl, int iImageIndex);
		
		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeParentBackground(IntPtr hWnd, IntPtr hdc, ref RECT pRect);
		
		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 DrawThemeParentBackground(IntPtr hWnd, IntPtr hdc, int pRect);
		
		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 DrawThemeText(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, String text, int textLength, UInt32 textFlags, UInt32 textFlags2, ref RECT pRect);
		
		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 EnableThemeDialogTexture(IntPtr hWnd, EnableThemeDialogTextureFlags flags);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 EnableTheming(int fEnable);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetCurrentThemeName(out StringBuilder stringThemeName, int lengthThemeName, out StringBuilder stringColorName, int lengthColorName, out StringBuilder stringSizeName, int lengthSizeName);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static ThemeAppProperties GetThemeAppProperties();

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeBackgroundContentRect(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pBoundingRect, out RECT pContentRect);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeBackgroundExtent(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, ref RECT pClipRect);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeBackgroundRegion(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, out IntPtr pRegion);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeBool(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int pfVal);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeColor(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out UInt32 pColor);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeDocumentationProperty(String stringThemeName, String stringPropertyName, out StringBuilder stringValue, int lengthValue);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeEnumValue(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeFilename(IntPtr hTheme, int iPartId, int iStateId, int iPropId, StringBuilder themeFileName, int themeFileNameLength);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeFont(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int iPropId, out LOGFONT pFont);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeInt(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeIntList(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out INTLIST pIntList);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeMargins(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out MARGINS pMargins);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeMetric(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out int piVal);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemePartSize(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, ref RECT pRect, ThemeSize eSize, out SIZE size);
		
		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemePartSize(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, int pRect, ThemeSize eSize, out SIZE size);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemePosition(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out POINT pPoint);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemePropertyOrigin(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out PropertyOrigin pOrigin);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeRect(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out RECT pRect);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeString(IntPtr hTheme, int iPartId, int iStateId, int iPropId, out StringBuilder themeString, int themeStringLength);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static int GetThemeSysBool(IntPtr hTheme, int iBoolId);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static IntPtr GetThemeSysBrush(IntPtr hTheme, int iColorId);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static UInt32 GetThemeSysColor(IntPtr hTheme, int iColorId);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeSysFont(IntPtr hTheme, int iFontId, out LOGFONT plf);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeSysInt(IntPtr hTheme, int iIntId, out int piVal);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static int GetThemeSysSize(IntPtr hTheme, int iSizeId);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeSysString(IntPtr hTheme, int iStringId, out StringBuilder stringSys, int stringSysLength);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeTextExtent(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, String text, int textLength, UInt32 textFlags, ref RECT boundingRect, out RECT extentRect);
		
		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 GetThemeTextExtent(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, String text, int textLength, UInt32 textFlags, int boundingRect, out RECT extentRect);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 GetThemeTextMetrics(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, out TEXTMETRIC textMetric);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static IntPtr GetWindowTheme(IntPtr hWnd);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static Int32 HitTestThemeBackground(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, UInt32 dwOptions, ref RECT pRect, IntPtr hrgn, POINT ptTest, out HitTestThemeBackgroundCode code); 

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static bool IsAppThemed();

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static bool IsThemeActive();

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static int IsThemeBackgroundPartiallyTransparent(IntPtr hTheme, int iPartId, int iStateId);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static int IsThemeDialogTextureEnabled(IntPtr hWnd);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static bool IsThemePartDefined(IntPtr hTheme, int iPartId, int iStateId);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public static extern IntPtr OpenThemeData(IntPtr hWnd, String classList);

		[DllImport("uxtheme.dll", ExactSpelling=true)]
		public extern static void SetThemeAppProperties(ThemeAppProperties props);

		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 SetWindowTheme(IntPtr hWnd, String textSubAppName, String textSubIdList);
		
		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 SetWindowTheme(IntPtr hWnd, int textSubAppName, String textSubIdList);
		
		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 SetWindowTheme(IntPtr hWnd, String textSubAppName, int textSubIdList);
		
		[DllImport("uxtheme.dll", ExactSpelling=true, CharSet=CharSet.Unicode)]
		public extern static Int32 SetWindowTheme(IntPtr hWnd, int textSubAppName, int textSubIdList);
	}
}
